package com.zhuang.designpattern.status;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.alibaba.fastjson.*;

/**
 * description: Test
 * date: 2022/9/21 17:02
 * author: Zhuang
 * version: 1.0
 */
public class Test {

    public static void main(String[] args) {
        Logger logger = LoggerFactory.getLogger(Test.class);

        String activityId1 = "100001";
        ActivityService.init(activityId1, Status.EDITING);

        StateHandler stateHandler1 = new StateHandler();
        Result result1 = stateHandler1.arraignment(activityId1, Status.EDITING);

        logger.info("测试结果(编辑中To提审活动)：{}", JSON.toJSONString(result1));
        logger.info("活动信息：{} 状态：{}", JSON.toJSONString(ActivityService.queryActivityInfo(activityId1)), JSON.toJSONString(ActivityService.queryActivityInfo(activityId1).getStatus()));


        String activityId2 = "100001";
        ActivityService.init(activityId2, Status.EDITING);

        StateHandler stateHandler2 = new StateHandler();
        Result result2 = stateHandler2.open(activityId2, Status.EDITING);

        logger.info("测试结果(编辑中To开启活动)：{}", JSON.toJSONString(result2));
        logger.info("活动信息：{} 状态：{}", JSON.toJSONString(ActivityService.queryActivityInfo(activityId2)), JSON.toJSONString(ActivityService.queryActivityInfo(activityId2).getStatus()));


        String activityId3 = "100001";
        ActivityService.init(activityId3, Status.REFUSE);

        StateHandler stateHandler3 = new StateHandler();
        Result result3 = stateHandler3.doing(activityId3, Status.REFUSE);

        logger.info("测试结果(拒绝To活动中)：{}", JSON.toJSONString(result3));
        logger.info("活动信息：{} 状态：{}", JSON.toJSONString(ActivityService.queryActivityInfo(activityId3)), JSON.toJSONString(ActivityService.queryActivityInfo(activityId3).getStatus()));


        String activityId4 = "100001";
        ActivityService.init(activityId4, Status.REFUSE);

        StateHandler stateHandler4 = new StateHandler();
        Result result4 = stateHandler4.checkRevoke(activityId4, Status.REFUSE);

        logger.info("测试结果(拒绝To撤审)：{}", JSON.toJSONString(result4));
        logger.info("活动信息：{} 状态：{}", JSON.toJSONString(ActivityService.queryActivityInfo(activityId4)), JSON.toJSONString(ActivityService.queryActivityInfo(activityId4).getStatus()));

    }
}
